package ch09.shili;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.List;

public class S11_B {

    public static void main(String[] args) {
        try(ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("data/personb.bb"))){
            List<Person> personList = new ArrayList<>();
            personList.add(new Person("小明",19,"男"));
            personList.add(new Person("小红",22,"女"));
            oos.writeObject(personList);
            System.out.println("序列化成功");
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
